package Others;

import java.awt.Component;

import javax.swing.plaf.basic.BasicInternalFrameTitlePane.MoveAction;

import GameSet.SnakeFrame;
import Snake.Snake;

public class SnakeRunnable implements Runnable {

	private Snake snake;
	private Component component;
	
	public SnakeRunnable(Snake snake, Component component) {
		this.snake = snake;
		this.component = component;
	}

	public void run() {
		while (true) {
			try {
				SnakeFrame.snakePanel.repaint();
				snake.move();
				component.repaint();
				Thread.sleep(snake.getSpeed());
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}

}
